package com.edu.method;

import java.util.Scanner;

public class MethodPractice05 {
    public static void main(String[] args) {
        //案例小总结：评委打分
        //比赛中，六位评委打分，去掉一个最高分、一个最低分，剩余四位求均值
        int[] a=new int[6];
        Scanner s = new Scanner(System.in);
        for (int i = 0; i < a.length; i++) {
            a[i]=s.nextInt();
        }
        System.out.println("均分为"+average(a));
        System.out.println("最高分为"+a[a.length-1]);
        System.out.println("最低分为"+a[0]);
    }

    public static double average(int[] a){
        //先将数组排序
        //冒泡排序
        for (int i = 0; i < a.length; i++) {
            for (int j = 1; j < a.length-i; j++) {
                if(a[i]>a[j]){
                    int temp=a[i];
                    a[i]=a[j];
                    a[j]=temp;
                }
            }
        }
        //求均值
        int sum=0;
        for (int i = 1; i <a.length-1 ; i++) {
            sum+=a[i];
        }

        return (sum*1.0)/(a.length-2);
    }
}
